﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Dynamic;
using M;
using Mysoft.MyCM.Scm;

namespace Mysoft.MyCM.Business.Scm
{
	/// <summary>
	/// 区域业务处理
	/// </summary>
	public class AreaBLL : BaseBLL
	{
		/// <summary>
		/// 根据区域Code查询区域唯一Id
		/// </summary>
		/// <param name="code">区域Code</param>
		/// <returns></returns>
		public Guid GetGuid(string code)
		{
			MValidator.CheckForEmptyString("区域代码", code);
			using (var client = ScmWebApiClientManager.Manager.GetClient())
			{
				var result = client.GetSync<ApiResult<Guid>>(string.Format("g/Area/GetAreaGUID/{0}", code));
				CheckResult(result);
				return result.Result;
			}
		}
		/// <summary>
		/// 获取所有区域记录，不包含区域关联的客户及服务信息
		/// </summary>
		/// <returns></returns>
		public List<Mysoft.MyCM.Scm.Area> GetAllAreas()
		{
			using (var client = ScmWebApiClientManager.Manager.GetClient())
			{
				var result = client.GetSync<ApiResult<List<Area>>>("g/Area/GetALLArea/");
				CheckResult(result);
				return result.Result;
			}
		}
	}
}
